package com.gitee.wsl.compose.modifier

import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.toggleable
import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.semantics.Role

interface ModifierStateScope:ModifierScope{
    fun selectable(selected: Boolean,
                   enabled: Boolean = true,
                   role: Role? = null,
                   onClick: () -> Unit){
        modifier = modifier.selectable(selected, enabled, role, onClick)
    }


    fun toggleable(
        value: Boolean,
        enabled: Boolean = true,
        role: Role? = null,
        onValueChange: (Boolean) -> Unit
    ){
        modifier = modifier.toggleable(value, enabled, role, onValueChange)
    }
}

class ModifierStateScopeImp(override var modifier: Modifier):ModifierStateScope

fun Modifier.state(block:ModifierStateScope.()->Unit): Modifier = ModifierStateScopeImp(this).apply(block).modifier

